package com.gongzhiyun.springboot3test.controller;

import com.gongzhiyun.springboot3test.base.PageBean;
import com.gongzhiyun.springboot3test.base.R;
import com.gongzhiyun.springboot3test.entity.message.TbReplyMessages;
import com.gongzhiyun.springboot3test.service.TbReplyMessagesService;
import com.gongzhiyun.springboot3test.vo.ParamsReply;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/reply")
@Tag(name = "留言回复相关功能")
public class TbReplyMessageController {
    private final TbReplyMessagesService tbReplyMessagesService;

    @Operation(summary = "添加回复",description = "添加回复")
    @PostMapping("/add")
    public R<String> add(@RequestBody ParamsReply reply) {
        return tbReplyMessagesService.Reply(reply);
    }

    @Operation(summary = "查询某个用户回复",description = "查询回复")
    @GetMapping("/queryByUid/{uid}/{pn}/{ps}/{order}")
    public R<List<TbReplyMessages>> queryByUid(@PathVariable("uid") Integer uid, @PathVariable("pn") Integer pn, @PathVariable("ps") Integer ps, @PathVariable("order") Integer order) {
        PageBean pageBean = new PageBean();
        pageBean.setPageNum(pn);
        pageBean.setPageSize(ps);
        pageBean.setOrder(order);
        return tbReplyMessagesService.queryByUid(uid, pageBean);
    }

    @Operation(summary = "点赞回复",description = "点赞回复")
    @GetMapping("/praise/{mrid}")
    public R<String> praise(@PathVariable("mrid") Integer mrid) {
        return tbReplyMessagesService.praise(mrid);
    }

    @Operation(summary = "删除回复",description = "删除回复")
    @GetMapping("/delete/{mrid}")
    public R<String> delete(@PathVariable("mrid") Integer mrid) {
        return tbReplyMessagesService.delete(mrid);
    }
}
